﻿Public Class AgregarDepartamento 
    Public Sub Mostrar()
        If guardar.Enabled = False Then
            guardar.Enabled = True
            cancelar.Enabled = True
            agregar.Enabled = False
            modificar.Enabled = False
            eliminar.Enabled = False
            imprimir.Enabled = False
            PanelArriba.Enabled = True
            PanelAbajo.Enabled = False
        Else
            cancelar.Enabled = False
            guardar.Enabled = False
            agregar.Enabled = True
            Modificar.Enabled = True
            Eliminar.Enabled = True
            imprimir.Enabled = True
            PanelArriba.Enabled = False
            PanelAbajo.Enabled = True
        End If
    End Sub
    Private Sub DepartamentoBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DepartamentoBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.DepartamentoBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbSolucionesEducativasDataSet)
    End Sub
    Private Sub AgregarDepartamento_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.pais' table. You can move, or remove it, as needed.
        Me.PaisTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.pais)
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.departamento' table. You can move, or remove it, as needed.
        Me.DepartamentoTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.departamento)
        Mostrar()

    End Sub

    Private Sub modificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles modificar.Click
        Mostrar()

    End Sub

    Private Sub agregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles agregar.Click
        BindingNavigatorAddNewItem.PerformClick()

        Mostrar()

    End Sub

    Private Sub cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelar.Click
        ErrorProvider1.SetError(PaiidComboBox, Nothing)
        Mostrar()
        Me.DepartamentoTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.departamento)
    End Sub

    Private Sub guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
        If DptdescripcionTextBox.Text.Length = 0 Then
            ErrorProvider1.SetError(DptdescripcionTextBox, "Debe ingresar un nombre para el departamento")
        Else
            ErrorProvider1.SetError(DptdescripcionTextBox, Nothing)


            DepartamentoBindingNavigatorSaveItem.PerformClick()
            MessageBox.Show("Se guardó el resgistro satisfactoriamente")
            Mostrar()
        End If

    End Sub

    Private Sub imprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imprimir.Click
        GridControl1.ShowPrintPreview()


    End Sub
End Class
